<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
        <link rel="shortcut icon" type="image/png" href="../img/favicon.png">
        <title></title>

        

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<link href="//fonts.googleapis.com/css?family=Lato:400,700" rel="stylesheet">
<link rel="stylesheet" href="../css/main.css">
        <link rel="stylesheet" href="../css/jsplumb-doc.css">

    </head>
    <body>
        <div class="navbar navbar-top navbar-fixed-top" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>

            <a class="navbar-brand" href="/"><img src="../../img/logo-medium-jsplumb.png"></a>
            <div class="community"></div>

        </div>

        <div class="navbar-collapse collapse nav-wrapper">
            <ul class="nav navbar-nav">
                <li><a href="../">DEMOS</a></li>
                <li><a href="../doc/home.html">DOCS</a></li>
                <li><a href="../apidocs/index.html">API</a></li>
                <li><a href="../download">DOWNLOAD</a></li>
                <li><a href="http://beta.jsplumbtoolkit.com/contact.html">CONTACT</a></li>
                <li><a href="https://blog.jsplumbtoolkit.com">BLOG</a></li>

            </ul>

            <div class="social-nav hidden-xs">
                <a href="http://twitter.com/jsplumblib" class="link"><span class="icon-twitter"></span></a>
                <a href="http://github.com/sporritt/jsplumb/" class="link"><span class="icon-github"></span></a>
                <a href="http://www.linkedin.com/company/jsplumb" class="link"><span class="icon-linkedin"></span></a>

            </div>
        </div><!--/.nav-collapse -->
    </div>
</div>

        <div class="container padding-top">
            <div class="row" id="docs">
                <div class="docs-nav col-xs-3" tabindex="0">
                    <ul>
<li><a href="changelog.html">Changelog</a></li>
<li>Required imports and basic setup<ul>
<li><a href="home.html#browser">Browser Compatibility</a></li>
<li><a href="home.html#setup">Setup</a></li>
<li><a href="home.html#doctype">Doctype</a></li>
<li><a href="home.html#imports">Required Imports</a></li>
<li><a href="home.html#initializing">Initializing jsPlumb</a></li>
<li><a href="home.html#multiple">Multiple jsPlumb Instances</a></li>
<li><a href="home.html#zindex">Z-Index Considerations</a></li>
<li><a href="home.html#container">Where does jsPlumb add elements?</a></li>
<li><a href="home.html#dragging">Element Dragging</a></li>
<li><a href="home.html#performance">Performance</a></li>
<li><a href="zooming.html">Zooming</a></li>
</ul>
</li>
<li><a href="defaults.html">Configuring Defaults</a></li>
<li><a href="basic-concepts.html">Basic Concepts</a><ul>
<li><a href="anchors.html">Anchors</a></li>
<li><a href="connectors.html">Connectors</a></li>
<li><a href="endpoints.html">Endpoints</a></li>
<li><a href="overlays.html">Overlays</a></li>
</ul>
</li>
<li><a href="connections.html">Establishing Connections</a><ul>
<li><a href="connections.html#programmatic">Programmatic Connections</a></li>
<li><a href="connections.html#common">Reusing Common Settings</a></li>
<li><a href="connections.html#detaching">Detaching Programmatic Connections</a></li>
<li><a href="connections.html#draganddrop">Drag and Drop Connections</a></li>
<li><a href="connections.html#sourcesandtargets">Elements as sources &amp; targets</a></li>
<li><a href="connections.html#maketarget">Element Targets</a></li>
<li><a href="connections.html#makesource">Element Sources</a></li>
<li><a href="connections.html#sourcefilter">Specifying drag source area</a></li>
</ul>
</li>
<li><a href="removing.html">Removing Connections/Endpoints</a></li>
<li><a href="parameters.html">Connection &amp; Endpoint Parameters</a></li>
<li><a href="types.html">Connection &amp; Endpoint Types</a></li>
<li><a href="events.html">Events</a><ul>
<li><a href="interceptors.html">Interceptors</a></li>
</ul>
</li>
<li>Appearance<ul>
<li><a href="paint-styles.html">Styling via Paint Styles</a></li>
<li><a href="styling-via-css.html">Styling via CSS</a></li>
</ul>
</li>
<li><a href="querying.html">Querying jsPlumb</a></li>
<li><a href="animation.html">Animation</a></li>
<li><a href="utilities.html">Utility Functions</a></li>
<li><a href="loader-support.html">Loader Support (RequireJS)</a></li>
<li>Examples<ul>
<li><a href="connect-examples.html">jsPlumb.connect</a></li>
<li><a href="draggable-connections-examples.html">Draggable Connections</a></li>
<li><a href="miscellaneous-examples.html">Miscellaneous</a></li>
</ul>
</li>
<li>Development<ul>
<li><a href="development.html">Which files are which?</a></li>
<li><a href="Build.html">Building jsPlumb</a></li>
<li><a href="development-documentation.html">Documentation while developing</a></li>
</ul>
</li>
</ul>
                </div>
                <div class="markdown-body col-xs-9">
                    <ul>
<li><a href="#nodes">Removing Nodes</a></li>
<li><a href="#connections">Removing Connections</a></li>
<li><a href="#endpoints">Removing Endpoints</a></li>
</ul>

<p><a name="nodes"></a></p>

<h3>Removing Nodes</h3>

<p>If you have configured a DOM element with jsPlumb in any way you should use jsPlumb to remove the element from the DOM.</p>

<p>To help you with this, jsPlumb offers two methods:</p>

<h4>jsPlumb.remove</h4>

<p>This removes an element from the DOM and all Connections and Endpoints associate with that element:</p>
<div class="highlight"><pre><code class="language-javascript" data-lang="javascript"><span class="kd">var</span> <span class="nx">conn</span> <span class="o">=</span> <span class="nx">jsPlumb</span><span class="p">.</span><span class="nx">connect</span><span class="p">({</span><span class="nx">source</span><span class="o">:</span><span class="s2">&quot;element1&quot;</span><span class="p">,</span> <span class="nx">target</span><span class="o">:</span><span class="s2">&quot;element2&quot;</span><span class="p">});</span>
<span class="p">...</span>
<span class="nx">jsPlumb</span><span class="p">.</span><span class="nx">remove</span><span class="p">(</span><span class="s2">&quot;element1&quot;</span><span class="p">);</span>
</code></pre></div>
<p><code>conn</code> is now detached and <code>element1</code> is gone from the DOM. </p>

<p>You can also pass a selector or DOM element to the <code>remove</code> method.</p>

<h4>jsPlumb.empty</h4>

<p>This removes all the child elements from some element, and all of the Connections and Endpoints associated with those child elements. Perhaps you have this markup:</p>
<div class="highlight"><pre><code class="language-xml" data-lang="xml"><span class="nt">&lt;ul</span> <span class="na">id=</span><span class="s">&quot;list&quot;</span><span class="nt">&gt;</span>
  <span class="nt">&lt;li</span> <span class="na">id=</span><span class="s">&quot;one&quot;</span><span class="nt">&gt;</span>One<span class="nt">&lt;/li&gt;</span>
<span class="nt">&lt;/ul&gt;</span>
</code></pre></div><div class="highlight"><pre><code class="language-javascript" data-lang="javascript"><span class="kd">var</span> <span class="nx">conn</span> <span class="o">=</span> <span class="nx">jsPlumb</span><span class="p">.</span><span class="nx">connect</span><span class="p">({</span><span class="nx">source</span><span class="o">:</span><span class="s2">&quot;one&quot;</span><span class="p">,</span> <span class="nx">target</span><span class="o">:</span><span class="s2">&quot;someOtherElement&quot;</span><span class="p">});</span>
<span class="p">...</span>
<span class="nx">jsPlumb</span><span class="p">.</span><span class="nx">empty</span><span class="p">(</span><span class="s2">&quot;list&quot;</span><span class="p">);</span>
</code></pre></div>
<p><code>conn</code> is now detached and the UL is empty.</p>

<p>You can also pass a selector or DOM element to the <code>empty</code> method.</p>

<h3>Removing Connections/Endpoints</h3>

<p>There are a number of different functions you can use to remove Connections and/or Endpoints.</p>

<p><a name="connections"></a></p>

<h3>Connections</h3>

<h5>Detaching a single connection</h5>

<p>To remove a single Connection, use <code>jsPlumb.detach</code>:</p>
<div class="highlight"><pre><code class="language-text" data-lang="text">var conn = jsPlumb.connect({ some params});
...
jsPlumb.detach(conn);
</code></pre></div>
<p>When you call <code>jsPlumb.detach</code> to remove a Connection, the Endpoints associated with that Connection may or may not also be deleted - it depends on the way the Connection was established. The Endpoints <em>will</em> be deleted under the following circumstances:</p>

<ul>
<li>you created the Connection using <code>jsPlumb.connect</code> and you did not set <code>deleteEndpointsOnDetach:false</code>.</li>
<li>the Connection was created via the mouse by a user on an element configured via <code>makeSource</code> which did not have <code>deleteEndpointsOnDetach:false</code> set.</li>
</ul>

<p>The Endpoints <em>will not</em> be deleted under the following circumstances:</p>

<ul>
<li>you created the Connection using <code>jsPlumb.connect</code> and you set <code>deleteEndpointsOnDetach:false</code></li>
<li>the Connection was created via the mouse by a user from an Endpoint registered with <code>addEndpoint</code>.</li>
<li>the Connection was created via the mouse by a user on an element configured via <code>makeSource</code> which had <code>deleteEndpointsOnDetach:false</code> set.</li>
</ul>

<h5>Detaching all Connections from a single element</h5>

<p>To detach all the Connections from some given element:</p>
<div class="highlight"><pre><code class="language-text" data-lang="text">jsPlumb.detachAllConnections(el, [params])
</code></pre></div>
<p><strong>el</strong> may be:</p>

<ul>
<li>a String representing an element id</li>
<li>a DOM element</li>
<li>a selector representing a single element</li>
</ul>

<p><strong>params</strong> is optional and may contain:</p>

<ul>
<li><strong>fireEvent</strong> - whether or not to fire a disconnection event. The default is true.</li>
</ul>

<h4>Detaching all Connections from every element</h4>

<p>To detach every Connection in jsPlumb:</p>
<div class="highlight"><pre><code class="language-text" data-lang="text">jsPlumb.detachEveryConnection();
</code></pre></div>
<p>This leaves all Endpoints in place according to the deletion rules outlined in the description of <code>jsPlumb.detach</code> above.</p>

<p><a name="endpoints"></a></p>

<h3>Endpoints</h3>

<h5>Deleting a single Endpoint</h5>

<p>To delete a single Endpoint:</p>
<div class="highlight"><pre><code class="language-text" data-lang="text">var ep = jsPlumb.addEndpoint(someElement, { ... });
...
jsPlumb.deleteEndpoint(ep);
</code></pre></div>
<p><strong>ep</strong> may be either:</p>

<ul>
<li>a String, representing an Endpoint&#39;s UUID (when you add an Endpoint you can provide a <code>uuid</code> member for that Endpoint)</li>
<li>an actual Endpoint object (as in the example above)</li>
</ul>

<h5>Deleting every Endpoint</h5>

<p>To delete every Endpoint in jsPlumb:</p>
<div class="highlight"><pre><code class="language-text" data-lang="text">jsPlumb.deleteEveryEndpoint();
</code></pre></div>
<p>This has the effect of removing every Endpoint and also every Connection. </p>

<p><strong>Note</strong> this method is quite similar to <code>jsPlumb.reset</code>, except that this method does not remove any event handlers that have been registered.</p>

                </div>
            </div>
        </div>

        <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-49979015-1', 'auto');
    ga('send', 'pageview');

</script>


    </body>
</html>
